var sWind = {};
sWind.Focus = {
	init : function(args) {
		this.iBox = $(args.iBox);
		this.slide = $(args.slide);
		this.sChild = $(args.sChild);
		this.dotBx = $(args.dotBx);
		this.prev = $(args.prev);
		this.next = $(args.next);
		this.dotEle = '';
		this.dots = args.dots;
		this.totle = this.sChild.length;
		this.inx = -1;
		this.duration = 500;
		this.interval = 5000;
		this.active = args.active;
		this.sActive = args.sActive;
		this.auto = args.auto ? args.auto:false;
		this.timer = null;

		this.start();
		this.snext();
		this.autoPlay();
		this.mouse();
	},
	start : function() {
		var that = this;
		if (that.totle === 1) {
			that.snext();
			return
		}
		that.dotEle = '<span></span>';
		$.each(that.sChild, function(i, el) {
			that.dotBx.append(that.dotEle);
		});
	},
	show : function(i) {
		var that = this,
			curr = that.sChild.filter(+'.'+that.active);
		that.dots = that.dotBx.children();
		that.sChild.stop(true, true);
		curr.removeClass(that.active).fadeOut(that.duration);
		that.sChild.eq(i).addClass(that.active).fadeIn(that.duration).siblings().removeClass(that.active).fadeOut(that.duration);
		that.dots && that.dots.removeClass(that.sActive).eq(i).addClass(that.sActive);
	},
	sprev : function() {
		var that = this;
		that.inx--;
		that.inx = that.inx < 0 ? that.totle - 1 : that.inx;
		that.show(that.inx);
	},
	snext : function() {
		var that = this;
		that.inx++;
		that.inx = that.inx > that.totle - 1 ? 0 : that.inx;
		that.show(that.inx);
	},
	autoPlay : function() {
		var that = this;
		if(!that.auto) return
		if (that.timer) clearInterval(that.timer);
		that.timer = setInterval(function() {
			that.snext();
		}, that.interval);
	},
	mouse : function() {
		var that = this;
		that.dots = that.dotBx.children();

		that.iBox.on('mouseenter', function() {
			if(that.timer) clearInterval(that.timer);
		}).on('mouseleave', function() {
			that.autoPlay();
		});


		that.prev.on('click', function() {that.sprev();});
		that.next.on('click', function() {that.snext();});

		that.dots.each(function() {
			var _this = $(this);
			_this.click(function() {
				var _j = _this.index();
				//if ($(this).filter(+'.'+that.sActive)) return;
				that.inx = _j;
				that.show(_j);
			})
		})
	}
};
